public class FraudThread implements Runnable {
    private final Bank bank;
    private final Account fromAccount;
    private final Account toAccount;
    private final long amount;

    public FraudThread(Bank bank, Account fromAccount, Account toAccount, long amount) {
        this.bank = bank;
        this.fromAccount = fromAccount;
        this.toAccount = toAccount;
        this.amount = amount;
    }

    @Override
    public void run() {
        try {
            if (bank.isFraud(fromAccount.getAccNumber(), toAccount.getAccNumber(), amount)) {
                fromAccount.setLocked(true);
                toAccount.setLocked(true);
            }
        } catch (InterruptedException ignored) {}
    }
}
